package com.fivec.javaproject.service;

import com.alibaba.fastjson.JSONObject;
import com.fivec.javaproject.Constants;
import com.fivec.javaproject.bean.*;
import com.fivec.javaproject.net.HttpUtils;

import java.net.URLEncoder;

/**
 * @author wangyizhu
 * @version "1.8.0_131"
 * @email 2641956765@qq.com
 * @desc:该类用于获取老黄历数据
 * @Time 2021/12/21 18:31
 */
public class HuangLiService {
    public HuangLi getCalendarMessage(String data) {
        data = URLEncoder.encode(data);
        String url = Constants.CnCalendar_URL
                + "?date=" + data +
                "&key=" + Constants.CnCalendar_KEY;
        String result = HttpUtils.get(url);
        //System.out.println(result);
        //json解析
       HuangLiCommon huangLiCommon = JSONObject.parseObject(result, HuangLiCommon.class);
        return huangLiCommon.result;
    }
}
